package com.booklove.domain.dto;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.booklove.domain.po.Books;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import okhttp3.internal.http.RetryAndFollowUpInterceptor;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * <p>
 * 许愿图书
 * </p>
 *
 * @author author
 * @since 2024-09-21
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("wishbook")
@ApiModel(value = "Wishbook对象", description = "许愿图书")
public class WishbookDTO implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "主键")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @ApiModelProperty(value = "许愿描述")
    private String content;

    @ApiModelProperty(value = "许愿封面")
    private String picture;

    @ApiModelProperty(value = "许愿标题")
    private String title;

    @ApiModelProperty(value = "捐赠地点")
    private Integer addressId;


//    @ApiModelProperty(value = "发出许愿的用户id")
//    private Integer userId;

//    @ApiModelProperty(value = "对应许愿的书籍id")
//    private Integer bookId;

//    @ApiModelProperty(value = "请求状态-数字字典给出") // 需要自动给赋值为waiting
//    private Integer wishState;

//    @ApiModelProperty(value = "创建人")
//    private Integer createdBy;
//
//    @ApiModelProperty(value = "创建时间")
//    private LocalDateTime createdTime;
//
//    @ApiModelProperty(value = "更新人")
//    private Integer updatedBy;
//
//    @ApiModelProperty(value = "更新时间")
//    private LocalDateTime updatedTime;


        /*
    书本本身信息
    除去书本的id和连接字段，其余信息均包含
     */

    @ApiModelProperty(value = "书名")
    private String bookName;

    @ApiModelProperty(value = "封面")
    private String bookCover;

    @ApiModelProperty(value = "内容描述")
    private String bookDescription;

    @ApiModelProperty(value = "书本的ISBN码")
    private String bookIsbn;

    @ApiModelProperty(value = "内容描述")
    private String bookContent; // 原始名称为content,需要换名处理

    @ApiModelProperty(value = "书本标签（冗余中）")
    private String bookLabel;


    /**
     * 构建books类型实体，不带id，需要id进行回填
     * @return
     */
    public Books buildBookEntity() {
        Books book = Books.builder()
                .name(this.getBookName())
                .cover(this.getBookCover())
                .description(this.getBookDescription())
                .isbn(this.getBookIsbn())
                .content(this.getBookContent())
                .label(this.getBookLabel())
                .build();

        return book;
    }

}
